package com.jjs.jcenterdemo;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.OrientationHelper;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Toast;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.jjs.jcenterdemo.adapterhelper.QqSimulateActivity;
import com.squareup.leakcanary.RefWatcher;
import com.white.commonlib.manager.LogManager;
import com.white.commonlib.utils.UIHelper;
import com.white.commonlib.widget.SettingItem;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity
{
    RecyclerView recycle;
    List<Bean> datas;
    SettingItem my_course;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        UIHelper.immersiveStatuesBar(this, getResources().getColor(R.color.main), null);
        my_course = (SettingItem) findViewById(R.id.my_course);
        my_course.setRightTxtStr("不和空间撒地方");
        recycle = (RecyclerView) findViewById(R.id.recycle);
        datas = new ArrayList<>();
        initData();
    }

    @Override
    protected void onStart()
    {
        super.onStart();
        LogManager.e("调用onStart");
    }

    @Override
    protected void onRestart()
    {
        super.onRestart();
        LogManager.e("调用onRestart");
    }


    @Override
    protected void onDestroy()
    {
        super.onDestroy();
        RefWatcher refWatcher = App.getInstance().getRefWatcher();//1
        refWatcher.watch(this);
    }

    BeanAdapter ad;

    private void initData()
    {
        for (int i = 0; i < 10; i++)
        {
            Bean b = new Bean("adsfsf", 1.09f);
            datas.add(b);
        }
        LinearLayoutManager l = new LinearLayoutManager(this, OrientationHelper.VERTICAL, false);
        recycle.setLayoutManager(l);
        ad = new BeanAdapter(R.layout.item, datas);
        recycle.setAdapter(ad);
        ad.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener()
        {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position)
            {
                Toast.makeText(MainActivity.this, "clicked", Toast.LENGTH_SHORT).show();
            }
        });
    }

    public void click(View view)
    {
        startActivity(new Intent(this, RippleBmpActivity.class));
//        startActivity(new Intent(this, LoginActivity.class));
//        startActivity(new Intent(this, WebViewActivity.class));
    }
}
